home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / lib / mathlib / libconv / TRY / graph.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  3.8 KB  |  172 lines

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <sys/time.h>
  4. #include <math.h>
  5. #include "conv.h"
  6.  
  7. /* --------- The following definitions change 
  8.         according to precision required -------- */
  9.  
  10.  
  11. #ifdef SINGLE       /* complex single precision    */
  12.  
  13. typedef float  this_variable;
  14.  
  15. #define OPS_PER_ITER    2
  16.  
  17. void  sfir1d_();
  18. #define MY_CONV            sfir1d_
  19. #define MY_RECU            siir1d_
  20. #define MY_CORR            scor1d_
  21. #define MY_INIT            sinit_
  22. #define TOLERANCE        1.e-5
  23.  
  24. #endif
  25. #ifdef DOUBLE            /* real double precision    */
  26.  
  27. typedef double  this_variable;
  28.  
  29. #define OPS_PER_ITER    2
  30.  
  31. void  dfir1d_(), ornl_dfir1d_(), simple_dfir1d_();
  32. #define MY_CONV            dfir1d_
  33. #define MY_RECU            diir1d_
  34. #define MY_CORR            dcor1d_
  35. #define MY_INIT            dinit_
  36. #define TOLERANCE        1.e-10
  37.  
  38. #endif
  39.  
  40. /* ---------- The rest is the same    ---------------- */
  41.  
  42. #define MAX_SIZE        55
  43. #define DEFAULT_TRIALS        999
  44. #define MAX_INC            5
  45. #define MAX_TIMES        3
  46.  
  47. #define ABS(a) ( ((a)>0) ? (a) : -(a))
  48. #define MAX(a,b) ( ((a) > (b)) ? (a) : (b))
  49. #define MIN(a,b) ( ((a) < (b)) ? (a) : (b))
  50.  
  51.     int nf, ng, nh;
  52.     int incf, nf1, nf2, incg, ng1, ng2, inch, nh1, nh2;
  53.     this_variable *vx, *vy, *vz, *vt, *vr;
  54.     this_variable alpha, beta;
  55.  
  56.     double t, x, y, z, u;
  57.  
  58. main(argc,argv)
  59. int argc;
  60. char *argv[];
  61. {
  62.     int i, j, k;
  63.  
  64. /* ******************************************************* */
  65.  
  66.  
  67.     get_values();
  68.  
  69.     fprintf(stderr,"(%3d,%3d,%3d | %2d,%3d,%3d | %2d,%3d,%3d | %5.2f | %2d,%3d,%3d | %5.2f): ",
  70.        nf,ng,nh, incf,nf1,nf2, incg,ng1,ng2, alpha, inch,nh1,nh2, beta);
  71.  
  72.     vx = (this_variable *)my_malloc(((nf+1)) * sizeof( this_variable));
  73.     vy = (this_variable *)my_malloc(((ng+1)) * sizeof( this_variable));
  74.     vz = (this_variable *)my_malloc(((nh+1)) * sizeof( this_variable));
  75.     vt = (this_variable *)my_malloc(((nh+1)) * sizeof( this_variable));
  76.     vr = (this_variable *)my_malloc(((nh+1)) * sizeof( this_variable));
  77.  
  78.     if( (vx == (this_variable *)0) || 
  79.     (vy == (this_variable *)0) ||
  80.     (vt == (this_variable *)0) ||
  81.     (vr == (this_variable *)0) ||
  82.     (vz == (this_variable *)0))  {
  83.     fprintf( stderr, "Malloc problem ... Exiting");
  84.     exit( -2);
  85.     }
  86.     i = MY_INIT( &nf, vx);
  87.     j = MY_INIT( &ng, vy);
  88. /*
  89.    *vy = 1.2;
  90. */
  91.     k = nh+1;
  92.     MY_INIT( &k, vz);
  93.  
  94.     do_it();
  95.  
  96.     print_it();
  97.  
  98.     my_free ( vx);
  99.     my_free ( vy);
  100.     my_free ( vz);
  101.     my_free ( vt);
  102.     my_free ( vr);
  103. }
  104.  
  105.  
  106. do_it() 
  107. {
  108.     int i, j, k;
  109.  
  110.     i = nf2-nf1+1;
  111.     j = ng2-ng1+1;
  112.     k = nh2-nh1+1;
  113.     MY_CONV(    vx,&incf,&nf1,&i,vy,&incg,&ng1,&j,
  114.             vz,&inch,&nh1,&k, &alpha, &beta);
  115.  
  116.  
  117.     MY_RECU(    vx,&incf,&nf1,&i,vy,&incg,&ng1,&j,
  118.             vr,&inch,&nh1,&k);
  119.  
  120.  
  121.     MY_CORR(    vx,&incf,&nf1,&i,vy,&incg,&ng1,&j,
  122.             vt,&inch,&nh1,&k);
  123. }
  124.  
  125. print_it() 
  126. {
  127.     int min, max, i;
  128.     min = MIN( MIN(nf1,ng1), nh1);
  129.     max = MAX( MAX(nf2,ng2), nh2);
  130.     for( i = min; i <= max ; i++) {
  131.     printf( "%d ", i);
  132.     printf( " %f", ( (i<nf1) || (i>nf2) ) ? (0.0) : (double)vx[(i-nf1)*incf]);
  133.     printf( " %f", ( (i<ng1) || (i>ng2) ) ? (0.0) : (double)vy[(i-ng1)*incg]);
  134.     printf( " %f", ( (i<nh1) || (i>nh2) ) ? (0.0) : (double)vz[(i-nh1)*inch]);
  135.     printf( " %f", ( (i<nh1) || (i>nh2) ) ? (0.0) : (double)vt[(i-nh1)*inch]);
  136.     printf( " %f", ( (i<nh1) || (i>nh2) ) ? (0.0) : (double)vr[(i-nh1)*inch]);
  137.     printf( "\n");
  138.     }
  139. }
  140.  
  141. get_values(){ 
  142.     fprintf(stderr, "Enter nf1 : ");
  143.     scanf( "%d", &nf1);
  144.     fprintf(stderr, "Enter nf2 : ");
  145.     scanf( "%d", &nf2);
  146.     fprintf(stderr, "Enter incf : ");
  147.     scanf( "%d", &incf);
  148.  
  149.     fprintf(stderr, "Enter ng1 : ");
  150.     scanf( "%d", &ng1);
  151.     fprintf(stderr, "Enter ng2 : ");
  152.     scanf( "%d", &ng2);
  153.     fprintf(stderr, "Enter incg : ");
  154.     scanf( "%d", &incg);
  155.  
  156.     fprintf(stderr, "Enter nh1 : ");
  157.     scanf( "%d", &nh1);
  158.     fprintf(stderr, "Enter nh2 : ");
  159.     scanf( "%d", &nh2);
  160.     fprintf(stderr, "Enter inch : ");
  161.     scanf( "%d", &inch);
  162.  
  163.     alpha = 1.;
  164.     beta = 0.;
  165.  
  166.     nf = nf2-nf1+1;
  167.     ng = ng2-ng1+1;
  168.     nh = nh2-nh1+1;
  169.     inirand_();
  170. }
  171.  
  172.